

import React, { Suspense } from "react";
import { Switch, Route, Redirect } from "react-router-dom";
// 引入    权限
import PrivateRoute from "./untils/PrivateRoute/PrivateRoute";
// import Login from "./pages/Login/Login";
// import Register from "./pages/Register/Register";
// import Index from "./pages/Index/Index";
// import List from "./pages/List/List";
// import Detail from "./pages/Detail/Detail";
// import Search from "./pages/Search/Search";
// import PrivateRoute from "./utils/PrivateRoute/PrivateRoute";
// 懒加载
let Register = React.lazy(() => import("./pages/Register/Register"));
let Index = React.lazy(() => import("./pages/Index/Index"));
let List = React.lazy(() => import("./pages/List/List"));
let Detail = React.lazy(() => import("./pages/Detail/Detail"));
let Search = React.lazy(() => import("./pages/Search/Search"));
let Login = React.lazy(() => import("./pages/Login/Login"));

export default function App() {
  return (
    <Suspense fallback={<div>正在努力加载中...</div>}>
      {/* 路由出口 */}
      <Switch>
        {/* 路由规则 */}
        <Route path="/login" component={Login}></Route>
        <Route path="/register" component={Register}></Route>
        <PrivateRoute path="/index" component={Index}></PrivateRoute>
        <PrivateRoute path="/list" component={List}></PrivateRoute>
        <PrivateRoute path="/detail/:id" component={Detail}></PrivateRoute>
        <PrivateRoute path="/search" component={Search}></PrivateRoute>
        {/* 重定向 */}
        <Redirect to="/login"></Redirect>
      </Switch>
    </Suspense>
  );
}
